home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / tools / jade / lisp / asm-mode.jl < prev    next >
Lisp/Scheme  |  1995-03-09  |  3KB  |  96 lines

  1. ;;;; asm-mode.jl -- Primitive mode for generic assembler code
  2. ;;;  Copyright (C) 1994 John Harper <jsh@ukc.ac.uk>
  3.  
  4. ;;; This file is part of Jade.
  5.  
  6. ;;; Jade is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 2, or (at your option)
  9. ;;; any later version.
  10.  
  11. ;;; Jade is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;;; GNU General Public License for more details.
  15.  
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with Jade; see the file COPYING.  If not, write to
  18. ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20. (provide 'asm-mode)
  21.  
  22. (defvar asm-indent t
  23.   "When non-nil lines are indented after being split in asm-mode.")
  24.  
  25. (defvar asm-comment ";"
  26.   "Strings which denotes the start of a comment in asm-mode.")
  27.  
  28. (defvar asm-keymap (make-keylist))
  29. (bind-keys asm-keymap
  30.   "RET" 'asm-ret
  31.   "Shift-RET" 'split-line
  32.   ":" 'asm-colon
  33.   "." 'asm-dot)
  34.  
  35. ;;;###autoload
  36. (defun asm-mode ()
  37.   "Asm Mode:\n
  38. Major mode for editing generic assembler source. Special commands are,\n
  39.   `RET'        break line and indent (unless asm-indent is nil)
  40.   `:'        undent line, then insert a tab
  41.   `.'        if line is not empty, delete its indentation, then insert
  42.         a dot."
  43.   (interactive)
  44.   (when major-mode-kill
  45.     (funcall major-mode-kill (current-buffer)))
  46.   (setq mode-name "Assembler"
  47.     major-mode 'asm-mode
  48.     major-mode-kill 'asm-mode-kill
  49.     mode-comment-fun 'asm-insert-comment
  50.     keymap-path (cons 'asm-keymap keymap-path))
  51.   (eval-hook 'asm-mode-hook))
  52.  
  53. ;;;###autoload
  54. (defun asm-cpp-mode ()
  55.   "Asm-CPP Mode:\n
  56. Major mode for editing assembler source which is passed through cpp before
  57. being assembled. Currently this only differs from asm-mode in the comments
  58. it inserts."
  59.   (interactive)
  60.   (when major-mode-kill
  61.     (funcall major-mode-kill (current-buffer)))
  62.   (setq mode-name "Assembler-CPP"
  63.     major-mode 'asm-cpp-mode
  64.     major-mode-kill 'asm-mode-kill
  65.     mode-comment-fun 'c-insert-comment
  66.     keymap-path (cons 'asm-keymap keymap-path))
  67.   (eval-hook 'asm-mode-hook)
  68.   (eval-hook 'asm-cpp-mode-hook))
  69.  
  70. (defun asm-mode-kill ()
  71.   (setq mode-name nil
  72.     major-mode nil
  73.     major-mode-kill nil
  74.     mode-comment-fun nil
  75.     keymap-path (delq 'asm-keymap keymap-path)))
  76.  
  77. (defun asm-ret ()
  78.   (interactive)
  79.   (insert (if asm-indent "\n\t" "\n")))
  80.  
  81. (defun asm-colon ()
  82.   (interactive)
  83.   (set-indent-pos (pos 0 nil))
  84.   (insert (if asm-indent ":\t" ":")))
  85.  
  86. (defun asm-dot ()
  87.   (interactive)
  88.   (when (empty-line-p)
  89.     (set-indent-pos (pos 0 nil)))
  90.   (insert "."))
  91.  
  92. (defun asm-insert-comment ()
  93.   (interactive)
  94.   (find-comment-pos)
  95.   (insert asm-comment))
  96.